from Base.base import Bases
from loctor.user_group_loctors import *
import allure
from time import sleep
from faker import Faker
faker = Faker(locale='zh_cn')
name = faker.name()
@allure.feature("用户分组流程")
class UserGroup(Bases):
    @allure.step("输入账号：{text}")
    def inputUser(self,text):
        self.input_texts(*userPassword,0,text)
    @allure.step("输入密码：{text}")
    def inputPwd(self,text):
        self.input_texts(*userPassword,1,text)
    @allure.step('点击登录')
    def clickLoginBtn(self):
        self.click_element(*loginBtn)
        sleep(5)
    @allure.step("点击用户tap")
    def clickUserTap(self):
        self.click_elements(*userIcon,1)
    @allure.step("点击用户分组")
    def clickUserGroup(self):
        self.click_element(*userGroup)
        sleep(2)
    @allure.step("点击添加分组")
    def clickAddGroup(self):
        self.click_element(*addGroupIcon)
        sleep(1)
    @allure.step("输入分组名称")
    def sendUserGroup(self):
        self.input_texts(*inputGroupUser,2,name)
    @allure.step("点击确认按钮")
    def clickAccept(self):
        self.click_elements(*acceptIcon,-1)
        sleep(3)
    @allure.step("断言，查看是否新增成功")
    def AssertGroup(self):
        text = self.find_element('xpath',f'//*[text()="{name}"]').text
        assert text == name